<template>
  <div class="home-content">
    <div class="flex-row square-item">
      <div class="flex-column item-left">
        <h2>扶摇短剧创作1.0模型</h2>
        <div>更生动流畅的短剧绘制工具</div>
        <div
          class="liner-button"
          @click="handleButton"
        >去创作→</div>
      </div>
      <img src="@/assets/home/square.png">
    </div>
    <el-tabs v-model="activeTabs" style="margin-top: 10px" @tab-click="handleTabsClick">
      <el-tab-pane
        v-for="item in tabs"
        :key="item.name"
        :label="item.label"
        :name="item.name"
      />
    </el-tabs>
    <div class="waterfall-content" :style="{ height: $baseTableHeight(120) + 'px' }">
      <waterfall v-if="worksList.length > 0" :col="4" :data="worksList" :gutter-width="10">
        <template>
          <div v-for="item in worksList" :key="item.id" class="waterfall-image">
            <el-image v-if="item['indexFileId']" :src="downloadUrl + item['indexFileId']" />
          </div>
        </template>
      </waterfall>
      <el-empty v-else class="empty-image" description="暂无数据" style="height: 100%">
        <template slot="image">
          <img src="@/assets/common/empty_role.png"/>
        </template>
      </el-empty>
    </div>
  </div>
</template>

<script>
import mixin from '@/views/mixin'
import { baseURL } from '@/config'
import { commonDownloadFile } from '@/api/config/uploadApi'
import { selectPlayDescInfo } from '@/api/play'
export default {
  name: 'Index',
  mixins: [mixin],
  data() {
    return {
      text: '',
      activeTabs: '3',
      tabs: [
        { label: '短剧', name: '3' },
        { label: '图片', name: '1' },
        { label: '视频', name: '2' }
      ],
      downloadUrl: `${baseURL}${commonDownloadFile}`,
      worksList: []
    }
  },
  mounted() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      selectPlayDescInfo({
        createStatus: '0',
        descType: this.activeTabs,
        desc: '1'
      }).then(res => {
        this.worksList = res.data.result
      })
    },
    // 去创作
    handleButton() {
      this.$router.push({
        path: '/skit-creation'
      })
    },
    // 切换标签
    handleTabsClick() {
      this.fetchData()
    }
  }
}
</script>
<style lang="scss" scoped>
.home-content {
  font-weight: 400;
  overflow-y: auto;
  height: 100%;
  overflow-x: hidden;
  background: $base-content-background;
  padding: 20px;
  box-sizing: border-box;
  border-radius: 8px;
  color: #FFFFFF;
  .square-item {
    flex: 1;
    background: #272C36;
    padding: 20px;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    height: 160px;
    justify-content: flex-end;
    color: #DCE8F3;
    &:before {
      content: '';
      position: absolute;
      inset: 0;
      z-index: 0;
      border-radius: 8px;
      background: linear-gradient(90deg, #2C4BFF, #04FFE0);
      mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
      -webkit-mask-composite: xor;
      mask-composite: exclude;
      padding: 1px;
    }
    .item-left {
      position: absolute;
      top: 20px;
      left: 40px;
      bottom: 20px;
      z-index: 1;
      right: 80%;
      >div:nth-child(2) {
        margin-top: 10px;
        color: #8C98A3;
      }
      .liner-button {
        margin-left: 0;
        margin-top: 20px;
        min-width: 0;
        width: 60px;
      }
    }
    img {
      width: 80%;
      height: 100%;
      border-radius: 8px;
      //object-fit: contain;
    }
  }
  .waterfall-content {
    overflow: hidden;
    .vue-waterfall {
      height: 100%;
    }
    .waterfall-image {
      height: 100%;
      position: relative;
      margin-top: 10px;
      .el-image {
        height: 100%;
        width: 100%;
        border-radius: 8px;
      }
    }
  }
}
::v-deep {
  .vue-waterfall.is-transition img {
    opacity: 1!important;
  }
}
</style>
